#pragma once
#include "protocol.h"

template<typename T>
class Message
{
public:
	Message(Protocol<T>* packet);
	virtual ~Message();
	virtual Protocol<T>* getPacket();
	virtual const Protocol<T>* getPacket() const;
	virtual void decodeBody() = 0;
	virtual void encodeBody() = 0;

protected:
	Protocol<T>* packet;
};

template<typename T>
Message<T>::Message(Protocol<T>* packet) : packet(packet)
{
}

template<typename T>
Message<T>::~Message()
{
	if (packet) {
		delete packet;
		packet = nullptr;
	}
}

template<typename T>
Protocol<T>* Message<T>::getPacket()
{
	return packet;
}

template<typename T>
inline const Protocol<T>* Message<T>::getPacket() const
{
	return packet;
}
